package day_2022_7_to_8.day48;
import java.util.List;
import java.util.LinkedList;
/**
 * 子集
 * @author haomin
 * @date 2022/07/15 12:25
 **/
public class Day1_2_Num78_Subsets {
    public List<List<Integer>> result = new LinkedList<>();
    public List<Integer> ret = new LinkedList<>();

    public List<List<Integer>> subsets(int[] nums) {
        dfs(nums, 0, nums.length);
        return result;
    }
    // 回溯
    public void dfs(int[] nums, int left,int right){
        result.add(new LinkedList<>(ret));

        for(int i = left;i < right;i++){
            ret.add(nums[i]);
            dfs(nums, i+1, right);
            ret.remove(ret.size()-1);
        }
    }
}